'''
Created on May 7, 2011

@author: james
'''

from EvaluatorHelper import EvaluatorHelper

class WeekendCallEvaluator(object):
    '''
    weekend calls (friday, saturday, sunday, holidays) should be evenly distributed
    '''

    def __init__(self, weekendCallIndex, initCount):
        self._weekendCallIndex = weekendCallIndex
        self._initCount = initCount
        
        
    def evaluate(self, chromosome, debug = False):

        counts = self._initCount.copy()
        
        for index in self._weekendCallIndex:
            doctor = chromosome[index]
            counts[doctor] += 1
        
        #score = EvaluatorHelper.maxPenalty(len (self._weekendCallIndex), len (self._initCount))
        score = len (self._weekendCallIndex)
        score -= EvaluatorHelper.calculateDistributionPenalty(counts, len (self._weekendCallIndex), len (self._initCount), score)
        
        if debug: print "WeekendCallEvaluator score: %d, %s" % (score, counts)
        
        return score        
    
    def evaluateConvergenceCriteria(self, chromosome, attempt):
        return True
        
        
    